package checkers3d.logic;

import checkers3d.presentation.IRenderResource;
import java.awt.Point;

/**
 *
 * @author Brenton Dong
 */
public class BoardObjectWall implements IBoardObject{

    Point drawPosition;
    private Player owner;
    IRenderResource resource;

    public BoardObjectWall(Player player, IRenderResource icon){
        setOwner(player);
        setDrawPosition(new Point());
        setRenderResource(icon);
    }

    public int getSetupCount(int boardSizeX, int boardSizeY, int boardSizeZ) {
        int setupCount = 2;

        return setupCount;
    }
    public Player getOwner() {
        return owner;
    }

    public void setOwner(Player player) {
        owner = player;
    }

    public boolean isBlocking() {
        return true;
    }

    public boolean isValidSetupPosition(PlayingSurface3D playingSurface3D, Point3D location) {
        boolean valid = false;

        if(!UtilBoardObject.isPositionBlocked(playingSurface3D.getPosition(location)))
            if(location.y >= (playingSurface3D.getSizeY() / 2))
                valid = true;

        return valid;
    }

    public boolean isVisibleTo(Object player) {//Walls are visible to all
        return true;
    }


//THIS NEEDS TO BE CHANGED LATER, IT IS ONLY TO PREVENT ERRORS
    public BoardObjectTouchEffect onTouch(IBoardObject other) {
        return BoardObjectTouchEffect.NOTHING;
    }

    public Point getDrawPosition() {
        return drawPosition;
    }

    public void setDrawPosition(Point position) {
        drawPosition = position;
    }

    public IRenderResource getRenderResource() {
        return resource;
    }

    public void setRenderResource(IRenderResource resource) {
        this.resource = resource;
    }

    public String getDataAsString() {
        return ("Wall\t" + owner.getDataAsString());
    }

    @Override
    public String toString() {
        return (getClass().getName() + " - owner:" + getOwner());
    }
    /**
     * Returns a new instance of this object type with all local variables the
     * same.
     *
     * @return A new instance of this object.
     * @see IBoardObject
     */
    @Override
    public IBoardObject clone()
    {
        return new BoardObjectWall(getOwner(), getRenderResource());
    }
}
